Skip to content

Conversation

@joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Sep 9, 2025


PR-Codex overview

This PR focuses on improving error handling and code consistency in various analytics utility functions, while also enhancing the formatting of numbers for display. It introduces better error messages and modifies the structure of some data being returned.

Detailed summary

  • Changed formatNumber to be an exported function in search.ts.
  • Improved error messages in several functions to specify the type of analytics data being fetched.
  • Updated the return structure in multiple analytics utility functions to use count instead of total.
  • Adjusted the grouping parameter from time to day in certain analytics queries.
  • Enhanced the calculation of daysDifference for analytics queries.
  • Added console logging for wallet analytics JSON responses.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Analytics now use daily grouping with dynamic result limits for clearer time-based insights.
  • Bug Fixes

    • Improved fetch error handling across analytics and transactions, with clearer messages including server details.
  • Refactor

    • Centralized number formatting for consistent display across analytics.
  • Chores

    • Enhanced reliability of total metrics retrieval and response parsing.
    • Added authentication to certain analytics requests.
    • Minor copy updates to error messages and added debug logging.

@vercel
Copy link

vercel bot commented Sep 9, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
thirdweb-www Ready Ready Preview Comment Sep 9, 2025 10:33am
4 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
docs-v2 Skipped Skipped Sep 9, 2025 10:33am
nebula Skipped Skipped Sep 9, 2025 10:33am
thirdweb_playground Skipped Skipped Sep 9, 2025 10:33am
wallet-ui Skipped Skipped Sep 9, 2025 10:33am

@vercel vercel bot temporarily deployed to Preview – docs-v2 September 9, 2025 10:24 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui September 9, 2025 10:24 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground September 9, 2025 10:24 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula September 9, 2025 10:24 Inactive
@changeset-bot
Copy link

changeset-bot bot commented Sep 9, 2025

⚠️ No Changeset found

Latest commit: 3508c03

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 9, 2025

Walkthrough

Exports formatNumber from "@/lib/search" and adopts it in ContractAnalyticsPage. Multiple analytics utilities switch aggregation from time to day, add dynamic day-window limits, and adjust parsing. Several utilities enhance error handling and response parsing. Total-count endpoints update aggregation aliases/fields and add headers. TransactionsSection adds explicit fetch error checks.

Changes

Cohort / File(s) Summary of Changes
Number formatting exposure and use
apps/dashboard/src/@/lib/search.ts, apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/ContractAnalyticsPage.tsx
Make formatNumber an exported constant; import and use it to format KPI values instead of toLocaleString().
Daily aggregation + windowed limits
.../analytics/utils/contract-function-breakdown.ts, .../analytics/utils/contract-transactions.ts, .../analytics/utils/contract-wallet-analytics.ts
Switch query grouping from time to day; compute daysDifference (default 30) and apply limit; adjust parsing from time to day and coerce numeric fields; maintain sort by time.
Totals endpoints adjustments
.../analytics/utils/total-contract-transactions.ts, .../analytics/utils/total-unique-wallets.ts
Change aggregation/response mapping from aliased total to count; add auth header in transactions totals; include response text in thrown errors on non-ok; return { count }.
Events analytics error messages
.../analytics/utils/contract-events.ts, .../analytics/utils/total-contract-events.ts
Update error messages to mention “events analytics”; on non-ok, read response.text() and include in error; success flow unchanged.
TransactionsSection fetch error handling
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/ai/components/TransactionsSection/TransactionsSection.tsx
Add explicit !response.ok checks in UI flow and useQuery queryFn, throwing errors with status and body; no API/signature changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI as Contract/Wallet/Tx Analytics UI
  participant Util as Analytics Utils
  participant API as Insights API

  rect rgba(220,235,245,0.4)
    note over UI,Util: Daily aggregation flow (changed: group_by=day, limit by daysDifference)
    UI->>Util: get*Analytics({ startDate, endDate })
    Util->>Util: daysDifference = ceil((end-start)/1d) || 30
    Util->>API: GET /insights?...&group_by=day&limit=daysDifference[ * 10 ]
    alt response ok
      API-->>Util: JSON with day, counts
      Util->>Util: Map day->Date, Number(count), sort asc
      Util-->>UI: Analytics entries
    else error
      API-->>Util: Status + text
      Util-->>UI: Throw Error("... analytics data: <text>")
    end
  end
Loading
sequenceDiagram
  autonumber
  participant UI as Totals UI
  participant Util as Totals Utils
  participant API as Insights API

  rect rgba(235,245,220,0.4)
    note over UI,Util: Totals flow (changed: count field, auth header)
    UI->>Util: getTotal*()
    Util->>API: GET /insights?...&aggregate=count()[ + x-client-id ]
    alt ok
      API-->>Util: JSON aggregations[0][0].count
      Util-->>UI: { count }
    else not ok
      API-->>Util: Status + text
      Util-->>UI: Throw Error("...: <text>")
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks (1 passed, 2 warnings)

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The current description retains only the commented template and a PR-Codex overview without filling in the required sections (title header, issue tag, reviewer notes, and testing instructions), so it does not conform to the repository’s PR description template. Populate the PR description by uncommenting and completing the template headings: add a properly formatted title or Linear issue tag, include Notes for the reviewer outlining any important context, and provide a How to test section with specific steps or tests to verify the changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title accurately and concisely reflects the primary changes introduced, namely updating the analytics API integration and improving number formatting for the dashboard, matching the pull request’s objectives without extraneous details.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch _Dashboard_Update_analytics_API_integration_and_improve_number_formatting

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label Sep 9, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@joaquim-verges joaquim-verges marked this pull request as ready for review September 9, 2025 10:26
@joaquim-verges joaquim-verges requested review from a team as code owners September 9, 2025 10:26
@codecov
Copy link

codecov bot commented Sep 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.62%. Comparing base (e2ebb60) to head (3508c03).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8023      +/-   ##
==========================================
- Coverage   56.65%   56.62%   -0.03%     
==========================================
  Files         904      904              
  Lines       58677    58677              
  Branches     4165     4161       -4     
==========================================
- Hits        33241    33225      -16     
- Misses      25330    25346      +16     
  Partials      106      106              
Flag Coverage Δ
packages 56.62% <ø> (-0.03%) ⬇️
see 5 files with indirect coverage changes
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

}

const json = (await res.json()) as InsightResponse;
console.log("wallet analytics json", json);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This console.log statement should be removed before merging as it appears to be debugging code. Logging large JSON objects to the console in production code can impact performance and potentially expose sensitive data in browser developer tools.

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 9, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.96 KB (0%) 1.3 s (0%) 341 ms (+180.71% 🔺) 1.7 s
thirdweb (cjs) 356.86 KB (0%) 7.2 s (0%) 1.1 s (+20.78% 🔺) 8.2 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 102 ms (+1298.63% 🔺) 217 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 91 ms (+3964.87% 🔺) 101 ms
thirdweb/react (minimal + tree-shaking) 19.15 KB (0%) 383 ms (0%) 97 ms (+509.51% 🔺) 480 ms

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (21)
apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-events.ts (1)

5-17: Align InsightResponse type with day-based grouping

Response parsing checks "day", but the type still models "time". Update the type to prevent drift.

 type InsightResponse = {
   aggregations: [
     Record<
       string,
       | {
-          time: string;
+          day: string;
           count: number;
         }
       | unknown
     >,
   ];
 };
apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-unique-wallets.ts (2)

36-41: Include HTTP status code in thrown error

Adds quick visibility into failures without digging into logs.

-  if (!res.ok) {
-    const errorText = await res.text();
-    throw new Error(
-      `Failed to fetch unique wallets analytics data: ${errorText}`,
-    );
-  }
+  if (!res.ok) {
+    const errorText = await res.text();
+    throw new Error(
+      `Failed to fetch unique wallets analytics data: ${res.status} ${res.statusText} - ${errorText}`,
+    );
+  }

45-47: Guard against missing aggregation; default to 0

Prevents runtime errors if the API returns an empty aggregation.

-  return {
-    count: json.aggregations[0][0].count,
-  };
+  return {
+    count: json.aggregations?.[0]?.[0]?.count ?? 0,
+  };
apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-events.ts (1)

35-38: Surface HTTP status in error

Consistent with other modules and improves debuggability.

-  if (!res.ok) {
-    const errorText = await res.text();
-    throw new Error(`Failed to fetch events analytics data: ${errorText}`);
-  }
+  if (!res.ok) {
+    const errorText = await res.text();
+    throw new Error(
+      `Failed to fetch events analytics data: ${res.status} ${res.statusText} - ${errorText}`,
+    );
+  }
apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-transactions.ts (1)

35-39: Add HTTP status to error

Brings this in line with other improved error messages.

-  if (!res.ok) {
-    const errorText = await res.text();
-    throw new Error(
-      `Failed to fetch transactions analytics data: ${errorText}`,
-    );
-  }
+  if (!res.ok) {
+    const errorText = await res.text();
+    throw new Error(
+      `Failed to fetch transactions analytics data: ${res.status} ${res.statusText} - ${errorText}`,
+    );
+  }
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/ai/components/TransactionsSection/TransactionsSection.tsx (2)

165-208: Set sensible cache staleness per guidelines

React Query defaults to staleTime 0. Dashboard guidelines recommend ≥60s.

   const txQuery = useQuery({
     enabled: !!account && !!activeChain,
     queryFn: async () => {
       if (!account || !activeChain) {
         return [];
       }
@@
     },
     queryKey: ["v1/wallets/transactions", account?.address, activeChain?.id],
-    retry: false,
+    retry: false,
+    staleTime: 60_000,
+    cacheTime: 5 * 60_000,
   });

1-11: Expose className on UI component root and merge via cn()

Matches the apps/dashboard TSX guideline and improves composability.

+import { cn } from "@/lib/utils";
@@
-export function TransactionSectionUI(props: {
-  data: WalletTransaction[];
-  isPending: boolean;
-  client: ThirdwebClient;
-}) {
+export function TransactionSectionUI(props: {
+  data: WalletTransaction[];
+  isPending: boolean;
+  client: ThirdwebClient;
+  className?: string;
+}) {
@@
-  return (
-    <div className="flex flex-col gap-1">
+  return (
+    <div className={cn("flex flex-col gap-1", props.className)}>

Also applies to: 26-60

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-function-breakdown.ts (3)

29-35: Clamp daysDifference to at least 1 to avoid limit=0

When startDate === endDate, ceil(...) can be 0 leading to no results.

-  const daysDifference =
-    params.startDate && params.endDate
-      ? Math.ceil(
-          (params.endDate.getTime() - params.startDate.getTime()) /
-            (1000 * 60 * 60 * 24),
-        )
-      : 30;
+  const daysDifference =
+    params.startDate && params.endDate
+      ? Math.max(
+          1,
+          Math.ceil(
+            (params.endDate.getTime() - params.startDate.getTime()) /
+              (1000 * 60 * 60 * 24),
+          ),
+        )
+      : 30;

60-62: Preserve server error details in thrown error

Align with other utils by including status and body.

-  if (!res.ok) {
-    throw new Error("Failed to fetch analytics data");
-  }
+  if (!res.ok) {
+    const errorText = await res.text();
+    throw new Error(
+      `Failed to fetch function breakdown analytics data: ${res.status} ${res.statusText} - ${errorText}`,
+    );
+  }

12-14: Update response typing to day-based shape

Keeps types in sync with "group_by=day".

-// This is weird aggregation response type, this will be changed later in insight
-type InsightResponse = {
-  aggregations: [Record<string, InsightAggregationEntry | unknown>];
-};
+// This is weird aggregation response type, this will be changed later in insight
+type InsightResponse = {
+  aggregations: [
+    Record<string, { function_selector: string; day: string; count: number } | unknown>
+  ];
+};
apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-transactions.ts (3)

33-39: Clamp daysDifference >= 1

Prevents limit=0 when dates are equal.

-  const daysDifference =
-    params.startDate && params.endDate
-      ? Math.ceil(
-          (params.endDate.getTime() - params.startDate.getTime()) /
-            (1000 * 60 * 60 * 24),
-        )
-      : 30;
+  const daysDifference =
+    params.startDate && params.endDate
+      ? Math.max(
+          1,
+          Math.ceil(
+            (params.endDate.getTime() - params.startDate.getTime()) /
+              (1000 * 60 * 60 * 24),
+          ),
+        )
+      : 30;

63-66: Include status in error message

Matches other utils and aids debugging.

-  if (!res.ok) {
-    const errorText = await res.text();
-    throw new Error(`Failed to fetch transaction analytics data: ${errorText}`);
-  }
+  if (!res.ok) {
+    const errorText = await res.text();
+    throw new Error(
+      `Failed to fetch transaction analytics data: ${res.status} ${res.statusText} - ${errorText}`,
+    );
+  }

5-17: Type InsightResponse to "day" buckets

Runtime checks look for "day"; update the type accordingly.

 type InsightResponse = {
   aggregations: [
     Record<
       string,
       | {
-          time: string;
+          day: string;
           count: number;
         }
       | unknown
     >,
   ];
 };
apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-wallet-analytics.ts (5)

33-39: Clamp daysDifference >= 1

Same rationale as other analytics utils.

-  const daysDifference =
-    params.startDate && params.endDate
-      ? Math.ceil(
-          (params.endDate.getTime() - params.startDate.getTime()) /
-            (1000 * 60 * 60 * 24),
-        )
-      : 30;
+  const daysDifference =
+    params.startDate && params.endDate
+      ? Math.max(
+          1,
+          Math.ceil(
+            (params.endDate.getTime() - params.startDate.getTime()) /
+              (1000 * 60 * 60 * 24),
+          ),
+        )
+      : 30;

64-67: Include HTTP status in error

Consistent with other modules.

-  if (!res.ok) {
-    const errorText = await res.text();
-    throw new Error(`Failed to fetch wallet analytics data: ${errorText}`);
-  }
+  if (!res.ok) {
+    const errorText = await res.text();
+    throw new Error(
+      `Failed to fetch wallet analytics data: ${res.status} ${res.statusText} - ${errorText}`,
+    );
+  }

70-70: Remove console.log or gate to non-production

Avoids noisy logs and possible data leakage in prod.

-  console.log("wallet analytics json", json);
+  if (process.env.NODE_ENV !== "production") {
+    // eslint-disable-next-line no-console
+    console.debug("wallet analytics json", json);
+  }

11-13: Type InsightResponse to "day" buckets

Matches the checks for tx.day.

       | {
-          time: string;
+          day: string;
           count: number;
         }

33-45: De-duplicate shared analytics query math

daysDifference/group_by/limit logic is repeated across multiple utils. Consider a small shared helper (e.g., "@/utils/analytics.ts") to compute days window and build query params; reduces drift.

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/ContractAnalyticsPage.tsx (2)

13-13: Avoid importing a tiny util from a heavy module to keep the client bundle lean

@/lib/search pulls in thirdweb/chains, invariant, and search helpers. Importing it in a client component just for formatNumber risks pulling unnecessary code into the bundle. Extract formatNumber into a lightweight util (e.g., @/lib/number) and import from there; optionally re-export from @/lib/search to preserve the API.

Apply this diff locally:

-import { formatNumber } from "@/lib/search";
+import { formatNumber } from "@/lib/number";

New file (lightweight):

// apps/dashboard/src/@/lib/number.ts
export const formatNumber = (num: number): string => {
  if (num >= 1_000_000) {
    return `${(num / 1_000_000).toLocaleString(undefined, {
      maximumFractionDigits: 1,
      minimumFractionDigits: 1,
    })}M`;
  }
  if (num >= 1_000) {
    return `${(num / 1_000).toLocaleString(undefined, {
      maximumFractionDigits: 1,
      minimumFractionDigits: 1,
    })}k`;
  }
  return num.toLocaleString(undefined, {
    maximumFractionDigits: num < 10 ? 2 : 1,
    minimumFractionDigits: 0,
  });
};

Optional: keep existing public surface by re-exporting in @/lib/search.ts:

// apps/dashboard/src/@/lib/search.ts
export { formatNumber } from "./number";

378-381: Type the render callback param for clarity

Annotate v to satisfy our explicit return/param typing guideline and improve readability.

-        render={(v) => {
+        render={(v: number) => {
           return <dd className="font-normal text-xl">{formatNumber(v)}</dd>;
         }}
apps/dashboard/src/@/lib/search.ts (1)

187-205: Export looks good; add explicit return type and consider extended suffixes

Add an explicit return type per our TS guidelines. Optionally extend to handle billions/trillions and negatives via Math.abs for thresholds.

Minimal typing fix:

-export const formatNumber = (num: number) => {
+export const formatNumber = (num: number): string => {

Optional extended formatter:

-export const formatNumber = (num: number): string => {
-  if (num >= 1000000) {
-    return `${(num / 1000000).toLocaleString(undefined, {
+export const formatNumber = (num: number): string => {
+  const n = Math.abs(num);
+  const sign = num < 0 ? "-" : "";
+  if (n >= 1_000_000_000_000) {
+    return `${sign}${(n / 1_000_000_000_000).toLocaleString(undefined, {
+      maximumFractionDigits: 1,
+      minimumFractionDigits: 1,
+    })}T`;
+  }
+  if (n >= 1_000_000_000) {
+    return `${sign}${(n / 1_000_000_000).toLocaleString(undefined, {
+      maximumFractionDigits: 1,
+      minimumFractionDigits: 1,
+    })}B`;
+  }
+  if (n >= 1_000_000) {
+    return `${sign}${(n / 1_000_000).toLocaleString(undefined, {
       maximumFractionDigits: 1,
       minimumFractionDigits: 1,
     })}M`;
   }
-  if (num >= 1000) {
-    return `${(num / 1000).toLocaleString(undefined, {
+  if (n >= 1_000) {
+    return `${sign}${(n / 1_000).toLocaleString(undefined, {
       maximumFractionDigits: 1,
       minimumFractionDigits: 1,
     })}k`;
   }
-  return num.toLocaleString(undefined, {
-    maximumFractionDigits: num < 10 ? 2 : 1,
+  return `${sign}${n.toLocaleString(undefined, {
+    maximumFractionDigits: n < 10 ? 2 : 1,
     minimumFractionDigits: 0,
-  });
+  })}`;
 };

If you extract formatNumber into a lightweight @/lib/number as suggested, re-export here to keep the public API stable:

export { formatNumber } from "./number";
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4284b9d and 3508c03.

📒 Files selected for processing (10)
  • apps/dashboard/src/@/lib/search.ts (1 hunks)
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/ContractAnalyticsPage.tsx (2 hunks)
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-events.ts (1 hunks)
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-function-breakdown.ts (2 hunks)
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-transactions.ts (3 hunks)
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-wallet-analytics.ts (3 hunks)
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-events.ts (1 hunks)
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-transactions.ts (3 hunks)
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-unique-wallets.ts (3 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/ai/components/TransactionsSection/TransactionsSection.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-events.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-unique-wallets.ts
  • apps/dashboard/src/@/lib/search.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-transactions.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/ContractAnalyticsPage.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/ai/components/TransactionsSection/TransactionsSection.tsx
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-events.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-transactions.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-function-breakdown.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-wallet-analytics.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-events.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-unique-wallets.ts
  • apps/dashboard/src/@/lib/search.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-transactions.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/ContractAnalyticsPage.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/ai/components/TransactionsSection/TransactionsSection.tsx
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-events.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-transactions.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-function-breakdown.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-wallet-analytics.ts
apps/{dashboard,playground-web}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/{dashboard,playground-web}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/* (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps
Use NavLink for internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Use cn() from @/lib/utils for conditional class logic
Use design system tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components (Node edge): Start files with import "server-only";
Client Components (browser): Begin files with 'use client';
Always call getAuthToken() to retrieve JWT from cookies on server side
Use Authorization: Bearer header – never embed tokens in URLs
Return typed results (e.g., Project[], User[]) – avoid any
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stable queryKeys for React Query cache hits
Configure staleTime/cacheTime in React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never import posthog-js in server components

Files:

  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-events.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-unique-wallets.ts
  • apps/dashboard/src/@/lib/search.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-transactions.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/ContractAnalyticsPage.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/ai/components/TransactionsSection/TransactionsSection.tsx
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-events.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-transactions.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-function-breakdown.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-wallet-analytics.ts
apps/{dashboard,playground}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/{dashboard,playground}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/_ (e.g., Button, Input, Tabs, Card)
Use NavLink for internal navigation to get active state handling
Use Tailwind CSS for styling; no inline styles
Merge class names with cn() from @/lib/utils for conditional classes
Stick to design tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components must start with import "server-only"; use next/headers, server‑only env, heavy data fetching, and redirect() where appropriate
Client Components must start with 'use client'; handle interactivity with hooks and browser APIs
Server-side data fetching: call getAuthToken() from cookies, send Authorization: Bearer <token> header, and return typed results (avoid any)
Client-side data fetching: wrap calls in React Query with descriptive, stable queryKeys and set sensible staleTime/cacheTime (≥ 60s default); keep tokens secret via internal routes or server actions
Do not import posthog-js in server components (client-side only)

Files:

  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-events.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-unique-wallets.ts
  • apps/dashboard/src/@/lib/search.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-transactions.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/ContractAnalyticsPage.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/ai/components/TransactionsSection/TransactionsSection.tsx
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-events.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-transactions.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-function-breakdown.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-wallet-analytics.ts
apps/{dashboard,playground}/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Expose a className prop on the root element of every component

Files:

  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/ContractAnalyticsPage.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/ai/components/TransactionsSection/TransactionsSection.tsx
🧠 Learnings (3)
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to src/@/analytics/report.ts : Analytics event name: human-readable `<subject> <verb>` (e.g., "contract deployed"); function: `report<Subject><Verb>` (PascalCase)

Applied to files:

  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-events.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-events.ts
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to src/@/analytics/report.ts : Review `src/@/analytics/report.ts` before adding analytics events to check for duplicates

Applied to files:

  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-events.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/ContractAnalyticsPage.tsx
📚 Learning: 2025-08-29T15:37:38.513Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: AGENTS.md:0-0
Timestamp: 2025-08-29T15:37:38.513Z
Learning: Applies to apps/{dashboard,playground}/src/@/analytics/report.ts : Analytics naming: event name as `<subject> <verb>`; helper function as `report<Subject><Verb>` (PascalCase)

Applied to files:

  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-events.ts
🧬 Code graph analysis (1)
apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/ContractAnalyticsPage.tsx (1)
apps/dashboard/src/@/lib/search.ts (1)
  • formatNumber (187-204)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Size
🔇 Additional comments (3)
apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/contract-events.ts (1)

62-65: Clearer error message — LGTM

The more specific failure text helps triage.

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/analytics/utils/total-contract-transactions.ts (1)

22-24: Query simplification — LGTM

Switching to aggregate=count() is cleaner and matches the returned shape.

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/ai/components/TransactionsSection/TransactionsSection.tsx (1)

194-198: Explicit non-ok handling — LGTM

Good call to throw with status and body; avoids parsing bogus JSON.

@joaquim-verges joaquim-verges merged commit 2f6f3a0 into main Sep 9, 2025
27 checks passed
@joaquim-verges joaquim-verges deleted the _Dashboard_Update_analytics_API_integration_and_improve_number_formatting branch September 9, 2025 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dashboard Involves changes to the Dashboard.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants